package com.security.controller;

import com.entity.ConditionType;
import com.entity.User;
import com.security.service.CacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cache")
public class CacheController {
    @Autowired
    CacheService cacheService;

    @GetMapping("/user/{type}")
    public List<User> search(@PathVariable ConditionType type) {
        return cacheService.searchAll(type);
    }

    @PostMapping("/user")
    public void add() {
        cacheService.add();
    }

    @DeleteMapping("/user")
    public void deleteAll() {
        cacheService.deleteAll();
    }

    @PutMapping("/user")
    public User update() {
        return cacheService.update();
    }
}
